package cn.wolfcode.luowowo.comment.domain;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 攻略评论
 */
@Setter
@Getter
@Document("scenic_comment")
public class ScenicComment implements Serializable {
    public static final int HASNT_PHOTO = 0; //没图
    public static final int HAS_PHOTO = 1; //有图
    @Id
    private String id;  //id
    private Long scenicId;  //景点id
    private String scenicName; //景点标题
    private Long userId;    //用户id
    private String username; //用户名
    private String userHeadUrl;   // 用户头像
    private String city; // 用户城市
    private int level; // 用户等级
//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime; // 创建时间
    private String content;  // 评论内容
    private String photoUrl; // 评论图片
    private int hasPhoto = HASNT_PHOTO; // 默认该评论没有图片
    private int synStarnum;
    private int sceneryStarnum;
    private int featureStarnum;
    private int serviceStarnum;
    private int thumbupnum;
    private int floor; // 楼层数

    public List<String> getPhotoUrlList(){
        ArrayList<String> list = new ArrayList<>();
        String[] split = photoUrl.split(",");
        for (String s : split) {
            String trim = s.trim();
            if(StringUtils.hasLength(trim)){
                list.add(trim);
            }
        }
        return list;
    }
}

